package com.oocl.service.impl;

import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.oocl.dao.UserDao;
import com.oocl.pojo.User;
import com.oocl.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService{
	@Resource(name="userDao")
	private UserDao userDao;

	@Override
	public User addUser(User user) {
		user.setId(UUID.randomUUID().toString());
		return userDao.addUser(user);
	}

	@Override
	public User findUserByUsername(String username) {
		return userDao.findUserByUsername(username);
	}

	@Override
	public boolean checkUser(User user) {
		User u = this.findUserByUsername(user.getUsername());
		if(null==u){
			return false;
		}
		if(!u.getPassword().equals(user.getPassword())){
			return false;
		}
		return true;
	}
	
}
